/*
 * Gate.h
 *
 * Created on: 05-05-2014
 *     Author: A.W. Janisse
 *
 * Version 1.0: 24-05-2014, Final release
 */

#ifndef GATE_H
#define GATE_H

#include <string>

using namespace std;

class Gate
{
    public:
        // pre:
        // post: A new object Gate is created with (left,top) equals (x,y) , type equals to type,
        //       number equals to nextNumber, nextNumber++.
        Gate(int x, int y, string type);

		// pre:
		// post: All the stored objects, if any, are freed from memory.
        virtual ~Gate();

		// pre:
		// post: Returns the X location of the gate.
        int getX();

		// pre:
		// post: Returns the Y location of the gate.
        int getY();

		// pre:
		// post: Returns the value of the nr field.
        int getNumber();

		// pre:
		// post: Returns a string which contains the gate type.
		//       Examples: OR, AND, NOT....
        string getType();

		// pre:
		// post: The value of nextNumber equals 1.
        static void resetNextNumber();

		// pre:
		// post: Please see decendants for a descripion.
        virtual int getOutputValue() = 0;

		// pre:
		// post: Please see decendants for a descripion.
        virtual bool connectEntryTo(Gate *gate) = 0;

		// pre:
		// post: Please see decendants for a descripion.
        virtual bool removeEntryTo(Gate *gate) = 0;

		// pre:
		// post: Returns a Gate at index nr if exist else return null.
        virtual Gate *getEntry(int nr) = 0;

		// pre:
		// post: Please see decendants for a descripion.
        virtual string getDrawingInstruction() = 0;

		// pre:
		// post: Return A string containing all information needed to store the gates in a file.
        string serialize();
     private:
        static int nextNumber;
        int nr;
        int x;
        int y;
        string type;
        static const int height = 6;
        static const int width = 6;
};

#endif
